//
//  SLBridgeLockCell.m
//  SlockApp
//
//  Created by 凯朱 on 2025/5/7.
//

#import "SLBridgeLockCell.h"

@implementation SLBridgeLockCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.backgroundColor = KClearColor;
    
    kWeakSelf(self);
    _icon.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
        if (weakself.deleteBlock) {
            weakself.deleteBlock(weakself.lockModel);
        }
    }];
    [_icon addGestureRecognizer:tap];
    
}

-(void)setLockModel:(SLLockModel *)lockModel{
    _lockModel = lockModel;
    _titleLbl.text = _lockModel.deviceName;
    _rightLbl.text = [kSTRING(_lockModel.onlineStatus) isEqualToString:@"1"] ? kLocalString(@"Oline") : kLocalString(@"Offline");
    if ([_rightLbl.text isEqualToString:kLocalString(@"Offline")]) {
        _rightLbl.textColor = KRedColor;
    }else{
        _rightLbl.textColor = KColor_placeholdar;
    }
}

-(void)setIsEditing:(BOOL)isEditing{
    _isEditing = isEditing;
    if (_isEditing) {
        _iconWidth.constant = 15;
        _iconRightSpace.constant = 12;
    }else{
        _iconWidth.constant = 0;
        _iconRightSpace.constant = 0;
    }
}

@end
